package com.lxy.u4springbootredis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Redis")
public class RedisTestController {
    @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping("/test")
    public String test(){
        //opsForValue()字符串操作
        redisTemplate.opsForValue().set("javaKey","tom");
        String javaKey = (String)redisTemplate.opsForValue().get("javaKey");
        System.out.println(javaKey);
        return javaKey;
    }
}
